<?php

namespace App\Repositories;

use App\Models\Question;
use Exception;

class QuestionRepository
{
    public function getList($filter = [])
    {
        $cache_key = "cache_question_list_" . md5(implode("_", array_values($filter)));
        $res = \Cache::get($cache_key);
        if (empty($res)) {
            $res = Question::query()
                ->where($filter)
                ->orderBy("id", "asc")
//                ->orderBy("sort", "desc")
                ->get()
                ->toArray();
            \Cache::set($cache_key, $res);
        }
        return $res;
    }
}
